package com.yzycoc.coc.gf;

import com.yzycoc.coc.gf.config.CocConfig;
import com.yzycoc.coc.gf.config.StartConfig;
import com.yzycoc.coc.gf.sdk.SdkDriver;
import com.yzycoc.coc.gf.task.TimeTask;
import com.yzycoc.form.ConfigInput;
import com.yzycoc.info.ModuleInfo;
import com.yzycoc.module.DriverCsRobot;
import com.yzycoc.module.ModuleManage;
import com.yzycoc.processor.event.Event;
import com.yzycoc.processor.send.Api;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;


/**
 * 机器人驱动
 *
 * @author 仓鼠
 * @version 1.0
 **/
@Slf4j
public class BotDriver implements DriverCsRobot {

    @Override
    public ModuleInfo info() {
        return ModuleInfo.builder()
                //SDK 保障唯一性
                .name("coc 国服")
                //简介说明
                .description("coc国服机器人")
                //版本
                .version("1.0.0")
                //作者
                .author("仓鼠")
                //作者头像
                .authorUrl("https://yzycoc.com/i/10")
                //作者主页
                .authorWeb("https://yzycoc.com")
                .background("https://pic1.imgdb.cn/item/67c809d9d0e0a243d40c9051.jpg")
                .build();
    }

    @Override
    public List<Event> event() {
        return Arrays.asList(new SdkDriver());
    }

    @Override
    public void api(Api api) {
        CocConfig.API = api;
    }

    @Override
    public ConfigInput config() {
        return null;
    }

    private Boolean SCHEDULED = false;
    @Override
    public void runSucceed() {
        StartConfig.startConfig();
        if(!SCHEDULED){
            ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
            scheduledExecutorService.scheduleAtFixedRate(new TimeTask(), 0, 60, TimeUnit.SECONDS);
            SCHEDULED = true;
        }
    }

}

